<?php
/*
 * Created on 18 d�c. 2005
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 
function & loadIniFile($fileName)
{
	$inifile = array();
	$matches = $current = 0;
	
	$fp = fopen($fileName, 'r');
	
	while ( $line=fgets($fp) )
	{
		if ( preg_match('/\[([a-z0-9_]+)\]/i', $line, $matches) )
		{
			$inifile[ $matches[1] ] = array();
			unset($current);

			$current = & $inifile[ $matches[1] ];
		}
		elseif ( preg_match('/([a-z0-9_]+)=(.*)/i', $line, $matches) )

			$current[ $matches[1] ] = trim($matches[2]);

	}
	
	fclose($fp);
	
	return $inifile;
}

function definedValue($iniFile, $section, $index)
{
	if ( array_key_exists($section, $iniFile) )
		return array_key_exists($index, $iniFile[$section]);
		
	else
		return false;
}

function getValue($iniFile, $section, $index)
{
	//print "$index\n";

	return $iniFile[$section][$index];
}
 
?>
